﻿using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using WMS.BasicData.Clients;
using WMS.BasicData.Clients.Dto;
using WMS.Pagination;

namespace WMS.Web.Controllers.BasicData.Client
{
    public class ClientController : Controller
    {
        /// <summary>
        /// 客户服务接口
        /// </summary>
        private readonly IClientAppService _clientAppService;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="clientAppService">客户服务接口</param>
        public ClientController(IClientAppService clientAppService)
        {
            _clientAppService = clientAppService;
        }

        /// <summary>
        /// 显示视图
        /// </summary>
        /// <returns>跳转到视图</returns>
        public IActionResult Index()
        {
            return View();
        }
        /// <summary>
        /// 添加客户信息
        /// </summary>
        /// <param name="clientDto">客户Dto</param>
        /// <returns>返回结果</returns>
        [HttpGet]
        public async Task<int> Insert(ClientDto clientDto)
        {
            var reslut = await _clientAppService.Insert(clientDto);
            return reslut;
        }
        /// <summary>
        /// 显示客户信息
        /// </summary>
        /// <param name="pageIndex">当前页</param>
        /// <param name="pageSize">页容量</param>
        /// <param name="chineseName">中文名称</param>
        /// <returns>返回结果</returns>
        [HttpGet]
        public async Task<PageResult> GetInquire(int pageIndex, int pageSize, string? chineseName)
        {
            var list = await _clientAppService.GetInquire(pageIndex, pageSize, chineseName);
            return list;
        }
        /// <summary>
        /// 删除客户信息
        /// </summary>
        /// <param name="ids">客户编号</param>
        /// <returns>返回结果</returns>
        [HttpGet]
        public async Task<int> Deleted(string ids)
        {
            var reslut = await _clientAppService.Deleted(ids);
            return reslut;
        }
        /// <summary>
        /// 编辑客户信息
        /// </summary>
        /// <param name="clientDto">客户Dto</param>
        /// <returns>返回结果</returns>
        [HttpGet]
        public async Task<int> Update(ClientDto clientDto)
        {
            var reslut = await _clientAppService.Update(clientDto);
            return reslut;
        }
    }
}
